package cn.semes.basic.util;


import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

public class EmailUtil {

   private static JavaMailSender javaMailSender = ApplicationContextUtil.getBean(JavaMailSender.class);

 public static void send(String result,String link) throws MessagingException {

     // 1.创建复杂邮件对象
     MimeMessage mimeMessage = javaMailSender.createMimeMessage();
     // 2.发送复杂邮件的工具类
     MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true,"utf-8");
     helper.setFrom("2270631431@qq.com");
     helper.setSubject("审核结果通知");
     // 3.设置文本内容，第二个参数 true 代表是否是一个html内容
     helper.setText("<h1>"+result+"</h1>"+
             link,true);
//     // 4.添加附件
//     helper.addAttachment("好东西.jpg",new File("C:\\Users\\colin\\Desktop\\1.jpg"));
     // 5.设置收件人
     helper.setTo("2674502499@qq.com");
     // 6.发送邮件
     javaMailSender.send(mimeMessage);
 }


}
